home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / os / sprite.X11R3 / RCS / utilities.c,v < prev   
Encoding:
Text File  |  1989-11-23  |  19.6 KB  |  1,035 lines

  1. head     1.18;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.18
  10. date     89.11.23.00.17.00;  author tve;  state Exp;
  11. branches ;
  12. next     1.17;
  13.  
  14. 1.17
  15. date     89.10.24.21.19.51;  author tve;  state Exp;
  16. branches ;
  17. next     1.16;
  18.  
  19. 1.16
  20. date     89.10.23.18.10.51;  author tve;  state Exp;
  21. branches ;
  22. next     1.15;
  23.  
  24. 1.15
  25. date     89.10.08.16.46.57;  author tve;  state Exp;
  26. branches ;
  27. next     1.14;
  28.  
  29. 1.14
  30. date     89.10.04.19.50.48;  author tve;  state Exp;
  31. branches ;
  32. next     1.13;
  33.  
  34. 1.13
  35. date     88.09.11.13.01.26;  author ouster;  state Exp;
  36. branches ;
  37. next     1.12;
  38.  
  39. 1.12
  40. date     88.09.09.09.00.21;  author ouster;  state Exp;
  41. branches ;
  42. next     1.11;
  43.  
  44. 1.11
  45. date     88.09.08.18.16.13;  author ouster;  state Exp;
  46. branches ;
  47. next     1.10;
  48.  
  49. 1.10
  50. date     88.08.26.16.12.56;  author brent;  state Exp;
  51. branches ;
  52. next     1.9;
  53.  
  54. 1.9
  55. date     88.08.26.16.04.18;  author deboor;  state Exp;
  56. branches ;
  57. next     1.8;
  58.  
  59. 1.8
  60. date     87.11.29.19.51.34;  author deboor;  state Exp;
  61. branches ;
  62. next     1.7;
  63.  
  64. 1.7
  65. date     87.11.01.20.23.24;  author deboor;  state Exp;
  66. branches ;
  67. next     1.6;
  68.  
  69. 1.6
  70. date     87.08.21.20.31.59;  author deboor;  state Exp;
  71. branches ;
  72. next     1.5;
  73.  
  74. 1.5
  75. date     87.08.04.17.28.24;  author deboor;  state Exp;
  76. branches ;
  77. next     1.4;
  78.  
  79. 1.4
  80. date     87.08.03.11.54.12;  author deboor;  state Exp;
  81. branches ;
  82. next     1.3;
  83.  
  84. 1.3
  85. date     87.07.07.18.16.44;  author deboor;  state Exp;
  86. branches ;
  87. next     1.2;
  88.  
  89. 1.2
  90. date     87.06.20.19.58.22;  author deboor;  state Exp;
  91. branches ;
  92. next     1.1;
  93.  
  94. 1.1
  95. date     87.06.11.17.47.26;  author deboor;  state Exp;
  96. branches ;
  97. next     ;
  98.  
  99.  
  100. desc
  101. @utility functions to hide the real operating system functions
  102. @
  103.  
  104.  
  105. 1.18
  106. log
  107. @commented out the "Aborting... see /tmp/..." message onto stdout.
  108. is was corrupting the rgb database
  109. @
  110. text
  111. @/*-
  112.  * utilities.c --
  113.  *    Various allocation and output utilities required by the
  114.  *    server.
  115.  *
  116.  * Copyright (c) 1987 by the Regents of the University of California
  117.  *
  118.  * Permission to use, copy, modify, and distribute this
  119.  * software and its documentation for any purpose and without
  120.  * fee is hereby granted, provided that the above copyright
  121.  * notice appear in all copies.  The University of California
  122.  * makes no representations about the suitability of this
  123.  * software for any purpose.  It is provided "as is" without
  124.  * express or implied warranty.
  125.  *
  126.  * TODO:
  127.  *    - Snarf stuff for compressed fonts from 4.2bsd/utils.c
  128.  *    - Add in support for !NOLOGOHACK
  129.  *
  130.  */
  131. #ifndef lint
  132. static char rcsid[] =
  133. "$Header: /mic/X11R3/src/cmds/Xsp/os/sprite/RCS/utilities.c,v 1.17 89/10/24 21:19:51 tve Exp Locker: tve $ SPRITE (Berkeley)";
  134. #endif lint
  135.  
  136. /*
  137.  * The following include file must be first, or this won't compile.
  138.  */
  139.  
  140. #include    <stdlib.h>
  141.  
  142. #include    "spriteos.h"
  143. #include    "opaque.h"
  144. #include    "input.h"
  145. #include    "site.h"
  146.  
  147. #include    <errno.h>
  148. #include    <status.h>
  149. #include    <stdio.h>
  150. #include    <string.h>
  151. #include    <sys/time.h>
  152. #include    <varargs.h>
  153.  
  154. extern long defaultScreenSaverInterval;
  155. extern long defaultScreenSaverTime;
  156. extern int defaultScreenSaverBlanking;
  157.  
  158. Bool    clientsDoomed = 0;
  159. int    debug = 0;
  160.  
  161. extern void KillServerResources();
  162.  
  163. /*-
  164.  *-----------------------------------------------------------------------
  165.  * AbortServer --
  166.  *    Abort the server...
  167.  *
  168.  * Results:
  169.  *    None.
  170.  *
  171.  * Side Effects:
  172.  *    The server dies in a Big Way.
  173.  *
  174.  *-----------------------------------------------------------------------
  175.  */
  176. void
  177. AbortServer()
  178. {
  179. /*
  180.     fprintf(stdout,
  181.     "Aborting... see /tmp/<hostname>:<display>.X11R3 for details\n");
  182.     fflush(stdout);
  183. */
  184.     panic ("Aborting...\n");
  185. }
  186. /*-
  187.  *-----------------------------------------------------------------------
  188.  * HangUp --
  189.  *    The server has been interrupted. Close everything down...
  190.  *
  191.  * Results:
  192.  *    None.
  193.  *
  194.  * Side Effects:
  195.  *    The process exits.
  196.  *
  197.  *-----------------------------------------------------------------------
  198.  */
  199. void
  200. HangUp ()
  201. {
  202.     KillServerResources();
  203.     exit (0);
  204. }
  205.  
  206. /*-
  207.  *-----------------------------------------------------------------------
  208.  * FatalError --
  209.  *    An error has occurred that does not allow the server to continue.
  210.  *    Print the given message and abort.
  211.  *
  212.  * Results:
  213.  *    None.
  214.  *
  215.  * Side Effects:
  216.  *    The server aborts/exits/dies/suicides/etc.
  217.  *
  218.  *-----------------------------------------------------------------------
  219.  */
  220. void
  221. FatalError (va_alist)
  222.     va_dcl
  223. {
  224.     va_list    ap;
  225.     va_start(ap);
  226.     ErrorF("\nFatal server bug!\n");
  227.     vErrorF(&ap);
  228.     ErrorF("\n");
  229.     AbortServer();
  230.     /*NOTREACHED*/
  231.     va_end(ap);
  232. }
  233.  
  234. /*-
  235.  *-----------------------------------------------------------------------
  236.  * Reset --
  237.  *    Tell DIX to reset itself when SIG_TERM is received.
  238.  *
  239.  * Results:
  240.  *    None.
  241.  *
  242.  * Side Effects:
  243.  *    clientsDoomed is set 1 and the dispatched is told to yield...
  244.  *
  245.  *-----------------------------------------------------------------------
  246.  */
  247. int
  248. Reset()
  249. {
  250.     clientsDoomed = 1;
  251.     SchedYield();
  252. }
  253.  
  254. /*-
  255.  *-----------------------------------------------------------------------
  256.  * GetTimeInMillis --
  257.  *    Return the current time in milliseconds. This really should be
  258.  *    the time since boot, since that's what's passed in the events,
  259.  *    but unfortunately, there's no way to get at that...
  260.  *
  261.  * Results:
  262.  *    The time since Jan 1, 1970 in milliseconds.
  263.  *
  264.  * Side Effects:
  265.  *    None.
  266.  *
  267.  *-----------------------------------------------------------------------
  268.  */
  269. long
  270. GetTimeInMillis()
  271. {
  272.     struct timeval tp;
  273.     struct timezone tzp;
  274.  
  275.     if (gettimeofday(&tp, &tzp) != 0) {
  276.     return 0;
  277.     }
  278.     return (tp.tv_sec*1000) + (tp.tv_usec/1000);
  279. }
  280.  
  281. /*-
  282.  *-----------------------------------------------------------------------
  283.  * ErrorF --
  284.  *    Print a formatted string on the error output.
  285.  *
  286.  * Results:
  287.  *    None.
  288.  *
  289.  * Side Effects:
  290.  *    Well...
  291.  *
  292.  *-----------------------------------------------------------------------
  293.  */
  294. void
  295. ErrorF(va_alist)
  296.     va_dcl
  297. {
  298.     va_list    ap;
  299.     char    *fmt;
  300.     va_start(ap);
  301.     fmt = va_arg(ap, char*);
  302.     vfprintf(stderr, fmt, ap);
  303.     fflush(stderr);
  304.     va_end(ap);
  305. }
  306.  
  307. /*-
  308.  *-----------------------------------------------------------------------
  309.  * vErrorF --
  310.  *    Same as ErrorF, but with varargs parameter.
  311.  *
  312.  * Results:
  313.  *    None.
  314.  *
  315.  * Side Effects:
  316.  *    Well...
  317.  *
  318.  *-----------------------------------------------------------------------
  319.  */
  320. void
  321. vErrorF(ap)
  322.     va_list    *ap;
  323. {
  324.     char    *fmt;
  325.     fmt = va_arg(*ap, char*);
  326.     vfprintf(stderr, fmt, *ap);
  327.     fflush(stderr);
  328. }
  329.  
  330. /*-
  331.  *-----------------------------------------------------------------------
  332.  * Error --
  333.  *    Report the status of the most recent operation.
  334.  *
  335.  * Results:
  336.  *    None.
  337.  *
  338.  * Side Effects:
  339.  *    A message is printed.
  340.  *
  341.  *-----------------------------------------------------------------------
  342.  */
  343. void
  344. Error (str)
  345.     char    *str;
  346. {
  347.     fprintf(stderr, "%s: %s\n", str, strerror(errno));
  348.     fflush(stderr);
  349. }
  350.  
  351. /*-
  352.  *-----------------------------------------------------------------------
  353.  * Notice --
  354.  *    Print something which should be noticed...
  355.  *
  356.  * Results:
  357.  *    None.
  358.  *
  359.  * Side Effects:
  360.  *    >...<
  361.  *
  362.  *-----------------------------------------------------------------------
  363.  */
  364. Notice()
  365. {
  366.     fprintf (stderr, "NOTE!\n");
  367.     fflush (stderr);
  368. }
  369.  
  370. UseMsg()
  371. {
  372.     ErrorF("use: X <display> [option] <tty>\n");
  373.     ErrorF("-a #                   mouse acceleration (pixels)\n");
  374.     ErrorF("-bp<:screen> color     BlackPixel for screen\n");
  375.     ErrorF("-c                     turns off key-click\n");
  376.     ErrorF("c #                    key-click volume (0-8)\n");
  377.     ErrorF("-co string             color database file\n");
  378.     ErrorF("-fc string             cursor font\n");
  379.     ErrorF("-fn string             default text font name\n");
  380.     ErrorF("-fp string             default text font path\n");
  381.     ErrorF("-p #                   screen-saver pattern duration (seconds)\n");
  382.     ErrorF("-r                     turns off auto-repeat\n");
  383.     ErrorF("r                      turns on auto-repeat \n");
  384.     ErrorF("-f #                   bell base (0-100)\n");
  385.     ErrorF("-x string              loads named extension at init time \n");
  386.     ErrorF("-help                  prints message with these options\n");
  387.     ErrorF("-s #                   screen-saver timeout (seconds)\n");
  388.     ErrorF("-t #                   mouse threshold (pixels)\n");
  389.     ErrorF("-to #                  connection time out\n");
  390.     ErrorF("v                      video blanking for screen-saver\n");
  391.     ErrorF("-v                     screen-saver without video blanking\n");
  392.     ErrorF("-wp<:screen> color     WhitePixel for screen\n");
  393.     ErrorF("There may be other device-dependent options as well\n");
  394. }
  395.  
  396. /*-
  397.  *-----------------------------------------------------------------------
  398.  * ProcessCommandLine --
  399.  *    Process the arguments the server was given and do something with
  400.  *    them.
  401.  *
  402.  * Results:
  403.  *    None.
  404.  *
  405.  * Side Effects:
  406.  *    Things may be set...
  407.  *
  408.  *-----------------------------------------------------------------------
  409.  */
  410. void
  411. ProcessCommandLine ( argc, argv )
  412.     int        argc;
  413.     char    *argv[];
  414.     
  415. {
  416.     int        i;
  417.     
  418.     for ( i = 1; i < argc; i++ )
  419.     {
  420.     /* initialize display */
  421.     if(argv[i][0] ==  ':')  
  422.     {
  423.         display = argv[i];
  424.         display++;
  425.     }
  426.     else if ( strcmp( argv[i], "-a") == 0)
  427.     {
  428.         if(++i < argc)
  429.             defaultPointerControl.num = atoi(argv[i]);
  430.         else
  431.         UseMsg();
  432.     }
  433.     else if ( strcmp( argv[i], "c") == 0)
  434.     {
  435.         if(++i < argc)
  436.             defaultKeyboardControl.click = atoi(argv[i]);
  437.         else
  438.         UseMsg();
  439.     }
  440.     else if ( strcmp( argv[i], "-c") == 0)
  441.     {
  442.         defaultKeyboardControl.click = 0;
  443.     }
  444.     else if ( strcmp( argv[i], "-co") == 0)
  445.     {
  446.         if(++i < argc)
  447.             rgbPath = argv[i];
  448.         else
  449.         UseMsg();
  450.     }
  451.     else if ( strcmp( argv[i], "-f") == 0)
  452.     {
  453.         if(++i < argc)
  454.             defaultKeyboardControl.bell = atoi(argv[i]);
  455.         else
  456.         UseMsg();
  457.     }
  458.     else if ( strcmp( argv[i], "-fc") == 0)
  459.     {
  460.         if(++i < argc)
  461.             defaultCursorFont = argv[i];
  462.         else
  463.         UseMsg();
  464.     }
  465.     else if ( strcmp( argv[i], "-fn") == 0)
  466.     {
  467.         if(++i < argc)
  468.             defaultTextFont = argv[i];
  469.         else
  470.         UseMsg();
  471.     }
  472.     else if ( strcmp( argv[i], "-fp") == 0)
  473.     {
  474.         if(++i < argc)
  475.             defaultFontPath = argv[i];
  476.         else
  477.         UseMsg();
  478.     }
  479.     else if ( strcmp( argv[i], "-help") == 0)
  480.     {
  481.         UseMsg();
  482.         exit(0);
  483.     }
  484.     else if ( strcmp( argv[i], "-p") == 0)
  485.     {
  486.         if(++i < argc)
  487.             defaultScreenSaverInterval = atoi(argv[i]) * MILLI_PER_MIN;
  488.         else
  489.         UseMsg();
  490.     }
  491.     else if ( strcmp( argv[i], "r") == 0)
  492.         defaultKeyboardControl.autoRepeat = 1;
  493.     else if ( strcmp( argv[i], "-r") == 0)
  494.         defaultKeyboardControl.autoRepeat = 0;
  495.     else if ( strcmp( argv[i], "-s") == 0)
  496.     {
  497.         if(++i < argc)
  498.             defaultScreenSaverTime = atoi(argv[i]) * MILLI_PER_MIN;
  499.         else
  500.         UseMsg();
  501.     }
  502.     else if ( strcmp( argv[i], "-t") == 0)
  503.     {
  504.         if(++i < argc)
  505.             defaultPointerControl.threshold = atoi(argv[i]);
  506.         else
  507.         UseMsg();
  508.     }
  509.     else if ( strcmp( argv[i], "-to") == 0)
  510.     {
  511.         if(++i < argc)
  512.         {
  513.             if((TimeOutValue = atoi(argv[i])) < 0)
  514.             TimeOutValue = DEFAULT_TIMEOUT;
  515.         }
  516.         else
  517.         UseMsg();
  518.     }
  519.     else if ( strcmp( argv[i], "v") == 0)
  520.         defaultScreenSaverBlanking = PreferBlanking;
  521.     else if ( strcmp( argv[i], "-v") == 0)
  522.         defaultScreenSaverBlanking = DontPreferBlanking;
  523.     else if ( strcmp( argv[i], "-x") == 0)
  524.     {
  525.         if(++i >= argc)
  526.         UseMsg();
  527.         /* For U**x, which doesn't support dynamic loading, there's nothing
  528.          * to do when we see a -x.  Either the extension is linked in or
  529.          * it isn't */
  530.     } else if ( strcmp( argv[i], "-d") == 0)
  531.     {
  532.         i += 1;
  533.         if (i >= argc) {
  534.         UseMsg();
  535.         } else {
  536.         char *opt;
  537.  
  538.         for (opt = argv[i]; *opt != '\0'; opt++) {
  539.             switch (*opt) {
  540.             case 's': debug |= DEBUG_SCHED; break;
  541.             case 'c': debug |= DEBUG_CONN; break;
  542.             case 'p': debug |= DEBUG_PDEV; break;
  543.             case 't': debug |= DEBUG_TCP; break;
  544.             case 'a': debug = ~0; break;
  545.             }
  546.         }
  547.         }
  548.     }
  549.     }
  550. }
  551.  
  552. /*-
  553.  *-----------------------------------------------------------------------
  554.  * Xalloc --
  555.  *    Allocate a chunk of memory.
  556.  *
  557.  * Results:
  558.  *    Pointer to the properly-aligned memory.
  559.  *
  560.  * Side Effects:
  561.  *    The program will exit if the allocator gets excited.
  562.  *
  563.  *-----------------------------------------------------------------------
  564.  */
  565. unsigned long *
  566. Xalloc (amount)
  567.     int        amount;        /* Amount of space required */
  568. {
  569.     return ((unsigned long *) malloc ((unsigned) amount));
  570. }
  571.  
  572. /*-
  573.  *-----------------------------------------------------------------------
  574.  * Xrealloc --
  575.  *    Enlarge a chunk of memory. The data will be copied if the
  576.  *    allocated block is too small to contain the new size.
  577.  *
  578.  * Results:
  579.  *    A pointer to the enlarged (and possibly moved) block.
  580.  *
  581.  * Side Effects:
  582.  *    The old block is freed.
  583.  *
  584.  *-----------------------------------------------------------------------
  585.  */
  586. unsigned long *
  587. Xrealloc (oldPtr, amount)
  588.     pointer oldPtr;
  589.     int        amount;
  590. {
  591.     return (unsigned long *) realloc((char *) oldPtr, (unsigned) amount);
  592. }
  593.  
  594. /*-
  595.  *-----------------------------------------------------------------------
  596.  * Xfree --
  597.  *    Free a block of storage.
  598.  *
  599.  * Results:
  600.  *    None.
  601.  *
  602.  * Side Effects:
  603.  *    The program will die if the block is already freed or is not
  604.  *    on the heap.
  605.  *
  606.  *-----------------------------------------------------------------------
  607.  */
  608. void
  609. Xfree (ptr)
  610.     pointer ptr;
  611. {
  612.     if (ptr != (pointer)NULL) {
  613.     free((char *) ptr);
  614.     } else {
  615.     ErrorF ("Freeing NULL pointer\n");
  616.     }
  617. }
  618. @
  619.  
  620.  
  621. 1.17
  622. log
  623. @fixed varargs stuff
  624. @
  625. text
  626. @d23 1
  627. a23 1
  628. "$Header: /mic/X11R3/src/cmds/Xsp/os/sprite/RCS/utilities.c,v 1.15 89/10/08 16:46:57 tve Exp Locker: tve $ SPRITE (Berkeley)";
  629. d69 1
  630. d73 1
  631. @
  632.  
  633.  
  634. 1.16
  635. log
  636. @fixed variable argument functions: use varargs.h
  637. @
  638. text
  639. @d69 4
  640. a72 1
  641.     panic ("Aborting...");
  642. d190 1
  643. a190 1
  644.     vfprintf(stderr, fmt, &ap);
  645. d214 1
  646. a214 1
  647.     vfprintf(stderr, fmt, ap);
  648. @
  649.  
  650.  
  651. 1.15
  652. log
  653. @cosmetics
  654. @
  655. text
  656. @d23 1
  657. a23 1
  658. "$Header: /mic/X11R3/src/cmds/Xsprite/os/sprite/RCS/utilities.c,v 1.14 89/10/04 19:50:48 tve Exp Locker: tve $ SPRITE (Berkeley)";
  659. d42 1
  660. a104 1
  661. /*VARARGS1*/
  662. d106 2
  663. a107 3
  664. FatalError (msg, v0, v1, v2, v3, v4, v5, v6, v7, v8)
  665.     char *msg;
  666.     char *v0, *v1, *v2, *v3, *v4, *v5, *v6, *v7, *v8;
  667. d109 2
  668. d112 1
  669. a112 1
  670.     ErrorF(msg, v0, v1, v2, v3, v4, v5, v6, v7, v8);
  671. d116 1
  672. d180 2
  673. a181 11
  674. ErrorF (fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9)
  675.     char    *fmt;
  676.     int        a1,
  677.         a2,
  678.         a3,
  679.         a4,
  680.         a5,
  681.         a6,
  682.         a7,
  683.         a8,
  684.         a9;
  685. d183 30
  686. a212 2
  687.     fprintf (stderr, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  688.     fflush (stderr);
  689. @
  690.  
  691.  
  692. 1.14
  693. log
  694. @fixed a few types
  695. @
  696. text
  697. @d23 1
  698. a23 1
  699. "$Header: utilities.c,v 1.13 88/09/11 13:01:26 ouster Exp $ SPRITE (Berkeley)";
  700. d83 1
  701. @
  702.  
  703.  
  704. 1.13
  705. log
  706. @Switch to use errno for errors.
  707. @
  708. text
  709. @d23 1
  710. a23 1
  711. "$Header: utilities.c,v 1.12 88/09/09 09:00:21 ouster Exp $ SPRITE (Berkeley)";
  712. d104 1
  713. d151 1
  714. a151 1
  715. int
  716. d206 1
  717. d273 1
  718. @
  719.  
  720.  
  721. 1.12
  722. log
  723. @Changes to compile with new C library.
  724. @
  725. text
  726. @d23 1
  727. a23 1
  728. "$Header: utilities.c,v 1.11 88/09/08 18:16:13 ouster Exp $ SPRITE (Berkeley)";
  729. d37 1
  730. d40 1
  731. d208 2
  732. a209 2
  733.     Stat_PrintMsg (stat_LastError, str);
  734.     fflush (stderr);
  735. @
  736.  
  737.  
  738. 1.11
  739. log
  740. @Intermediate check-in while converting to new C library.
  741. @
  742. text
  743. @d23 1
  744. a23 1
  745. "$Header: utilities.c,v 1.10 88/08/26 16:12:56 brent Exp $ SPRITE (Berkeley)";
  746. d26 6
  747. d37 2
  748. a38 1
  749. #include    <stdlib.h>
  750. d449 1
  751. a449 1
  752.     return (long *) realloc((char *) oldPtr, (unsigned) amount);
  753. @
  754.  
  755.  
  756. 1.10
  757. log
  758. @Nuked reference to DEBUG_NEWPDEV
  759. @
  760. text
  761. @d23 1
  762. a23 1
  763. "$Header: utilities.c,v 1.9 88/08/26 16:04:18 deboor Exp $ SPRITE (Berkeley)";
  764. d31 2
  765. a32 1
  766. #include    <sys.h>
  767. d38 1
  768. a38 1
  769. Bool    clientsDoomed = FALSE;
  770. d59 1
  771. a59 1
  772.     Sys_Panic (SYS_FATAL, "Aborting...");
  773. d77 1
  774. a77 1
  775.     Proc_Exit (0);
  776. d115 1
  777. a115 1
  778.  *    clientsDoomed is set TRUE and the dispatched is told to yield...
  779. d122 1
  780. a122 1
  781.     clientsDoomed = TRUE;
  782. d144 2
  783. a145 1
  784.     SpriteTime      now;
  785. d147 4
  786. a150 3
  787.     Sys_GetTimeOfDay (&now, (int *)NULL, (Boolean *)NULL);
  788.  
  789.     return (now.seconds * 1000 + now.microseconds / 1000);
  790. d179 2
  791. a180 2
  792.     Io_PrintStream (io_StdErr, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  793.     Io_Flush (io_StdErr);
  794. d200 1
  795. a200 1
  796.     Io_Flush (io_StdErr);
  797. d218 2
  798. a219 2
  799.     Io_PrintStream (io_StdErr, "NOTE!\n");
  800.     Io_Flush (io_StdErr);
  801. d343 1
  802. a343 1
  803.         defaultKeyboardControl.autoRepeat = TRUE;
  804. d345 1
  805. a345 1
  806.         defaultKeyboardControl.autoRepeat = FALSE;
  807. d420 1
  808. a420 1
  809.     return ((unsigned long *)Mem_Alloc (amount));
  810. d442 1
  811. a442 19
  812.     pointer newPtr;
  813.     extern char end[];
  814.     
  815.     if (oldPtr != (pointer) NULL) {
  816.     if (oldPtr < (pointer)end || oldPtr > (pointer)&newPtr) {
  817.         FatalError ("Trying to Xrealloc non-dynamic storage");
  818.     }
  819.     
  820.         if (Mem_Size (oldPtr) >= amount) {
  821.         return ((unsigned long *)oldPtr);
  822.     } else {
  823.         newPtr = (pointer)Mem_Alloc (amount);
  824.         Byte_Copy (Mem_Size (oldPtr), oldPtr, newPtr);
  825.         Mem_Free (oldPtr);
  826.     }
  827.     } else {
  828.     newPtr = (pointer)Mem_Alloc (amount);
  829.     }
  830.     return ((unsigned long *)newPtr);
  831. d464 1
  832. a464 1
  833.     Mem_Free (ptr);
  834. @
  835.  
  836.  
  837. 1.9
  838. log
  839. @Added FatalError
  840. @
  841. text
  842. @d23 1
  843. a23 1
  844. "$Header: utilities.c,v 1.8 87/11/29 19:51:34 deboor Exp $ SPRITE (Berkeley)";
  845. a390 1
  846.             case 'n': debug |= DEBUG_NEWPDEV; break;
  847. @
  848.  
  849.  
  850. 1.8
  851. log
  852. @Added setting of debug flags from command-line
  853. @
  854. text
  855. @d16 3
  856. d23 1
  857. a23 1
  858. "$Header: utilities.c,v 1.7 87/11/01 20:23:24 deboor Exp $ SPRITE (Berkeley)";
  859. d40 1
  860. a40 1
  861. extern void KilServerResources();
  862. d77 26
  863. @
  864.  
  865.  
  866. 1.7
  867. log
  868. @adapted to full release
  869. @
  870. text
  871. @d20 1
  872. a20 1
  873. "$Header: utilities.c,v 1.6 87/08/21 20:31:59 deboor Exp $ SPRITE (Berkeley)";
  874. d35 2
  875. d349 19
  876. @
  877.  
  878.  
  879. 1.6
  880. log
  881. @Added Reset function to kill all clients and loop on SIG_TERM
  882. @
  883. text
  884. @d20 1
  885. a20 1
  886. "$Header: utilities.c,v 1.5 87/08/04 17:28:24 deboor Exp $ SPRITE (Berkeley)";
  887. d26 1
  888. d28 6
  889. d35 1
  890. d39 18
  891. d70 1
  892. a70 2
  893.     clientsDoomed = TRUE;
  894.     CloseDownDevices();
  895. d188 26
  896. d235 5
  897. a239 5
  898.     for ( i = 1; i < argc; i++ ) {
  899.     if(argv[i][0] ==  ':')  {
  900.         /*
  901.          * Display number
  902.          */
  903. d242 17
  904. a258 35
  905.     } else if ( strcmp( argv[i], "-fp") == 0) {
  906.         /*
  907.          * Font path (single directory ending with '/'!)
  908.          */
  909.         defaultFontPath = argv[++i];
  910.     } else if ( strcmp( argv[i], "-fn") == 0) {
  911.         /*
  912.          * Default font
  913.          */
  914.         defaultTextFont = argv[++i];
  915.     } else if ( strcmp( argv[i], "-fc") == 0) {
  916.         /*
  917.          * Cursor font
  918.          */
  919.         defaultCursorFont = argv[++i];
  920.     } else if ( strcmp( argv[i], "-a") == 0) {
  921.         /*
  922.          * Pointer acceleration (whole units only)
  923.          */
  924.         defaultPointerControl.num = atoi(argv[++i]);
  925.         defaultPointerControl.den = 1;
  926.     } else if ( strcmp( argv[i], "-t") == 0) {
  927.         /*
  928.          * Pointer acceleration threshold
  929.          */
  930.         defaultPointerControl.threshold = atoi(argv[++i]);
  931.     } else if ( strcmp( argv[i], "-f") == 0) {
  932.         /*
  933.          * "Feep" volume
  934.          */
  935.         defaultKeyboardControl.bell = atoi(argv[++i]);
  936.     } else if ( strcmp( argv[i], "-c") == 0) {
  937.         /*
  938.          * Keyclick off
  939.          */
  940. d260 87
  941. a346 5
  942.     } else if ( strcmp( argv[i], "c") == 0) {
  943.         /*
  944.          * Keyclick on and volume
  945.          */
  946.         defaultKeyboardControl.click = atoi(argv[++i]);
  947. @
  948.  
  949.  
  950. 1.5
  951. log
  952. @Added protection against freeing NULL pointers
  953. @
  954. text
  955. @d20 1
  956. a20 1
  957. "$Header: utilities.c,v 1.4 87/08/03 11:54:12 deboor Exp $ SPRITE (Berkeley)";
  958. d47 20
  959. @
  960.  
  961.  
  962. 1.4
  963. log
  964. @adapted to new X*alloc declarations
  965. @
  966. text
  967. @d20 1
  968. a20 1
  969. "$Header: utilities.c,v 1.3 87/07/07 18:16:44 deboor Exp $ SPRITE (Berkeley)";
  970. d294 5
  971. a298 1
  972.     Mem_Free (ptr);
  973. @
  974.  
  975.  
  976. 1.3
  977. log
  978. @???
  979. @
  980. text
  981. @d20 1
  982. a20 1
  983. "$Header: utilities.c,v 1.2 87/06/20 19:58:22 deboor Exp $ SPRITE (Berkeley)";
  984. d229 1
  985. a229 1
  986. pointer
  987. d233 1
  988. a233 1
  989.     return ((pointer)Mem_Alloc (amount));
  990. d250 1
  991. a250 1
  992. pointer
  993. d264 1
  994. a264 1
  995.         return (oldPtr);
  996. d273 1
  997. a273 1
  998.     return (newPtr);
  999. @
  1000.  
  1001.  
  1002. 1.2
  1003. log
  1004. @adapted to Beta-0 and "debugged"
  1005. @
  1006. text
  1007. @d20 1
  1008. a20 1
  1009. "$Header: utilities.c,v 1.1 87/06/11 17:47:26 deboor Exp $ SPRITE (Berkeley)";
  1010. d120 1
  1011. a120 1
  1012.     Stat_PrintMsg (stat_LastStatus, str);
  1013. @
  1014.  
  1015.  
  1016. 1.1
  1017. log
  1018. @Initial revision
  1019. @
  1020. text
  1021. @d20 1
  1022. a20 1
  1023. "$Header$ SPRITE (Berkeley)";
  1024. d27 2
  1025. d44 1
  1026. d49 19
  1027. d69 5
  1028. d101 1
  1029. d120 2
  1030. a121 1
  1031.     Io_PrintStream (io_StdErr, "%s: system error...\n", str);
  1032. d140 1
  1033. d273 1
  1034. @
  1035.